package campus.controller;

import campus.model.CredentialsLog;
import campus.model.CredentialsLogSchedule;
import campus.model.Subjects;
import campus.service.CredentialsLogService;
import campus.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * @author ：wang
 * @description：凭证
 * @date ：2020/5/9 22:35
 */
@RequestMapping("CredentialsLog")
@CrossOrigin
@RestController
public class CredentialsLogController {
    @Autowired
    private CredentialsLogService credentialsLogService;
    /*
     * @Author: wang
     * @Description:添加
     * @Date: 1:15 2020/5/10
     * @param: credentialsLog
     * @return: void
     */
    @RequestMapping(value = "insert",method = RequestMethod.POST)
    public void insert(@RequestBody CredentialsLog credentialsLog) throws ParseException {
        //System.err.println(credentialsLog);
        credentialsLogService.insert(credentialsLog);
    }
    @RequestMapping(value = "insert1",method = RequestMethod.POST)
    public void insert1(@RequestBody CredentialsLog credentialsLog) {
        //System.err.println(credentialsLog);
        credentialsLogService.insert1(credentialsLog);
    }
    /*
     * @Author: wang
     * @Description:查询
     * @Date: 1:15 2020/5/10
     * @param:
     * @return: java.util.List<campus.model.CredentialsLog>
     */
    @RequestMapping(value = "selectByExample",method = RequestMethod.GET)
    public List<CredentialsLog> selectByExample(){
       return credentialsLogService.selectByExample();
    }

    /**
     * @name  凭证分页
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "selectByAllPageSize/{pageNum}/{pageSize}",method = RequestMethod.POST)
    public PageResult selectByAllPageSize(@RequestBody CredentialsLogSchedule record , @PathVariable("pageNum") int pageNum , @PathVariable("pageSize") int pageSize){
        PageResult findallpage = credentialsLogService.selectByAllPageSize(record,pageNum, pageSize);
        return findallpage;
    }

    /**
      * @name  单删
     * @Author VULCAN
     * @Date 2020/5/10 19:27
     */
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    public void delete(@RequestBody CredentialsLogSchedule record){
         credentialsLogService.delete(record);
    }
    /**
     * @name  批量删除
     * @Author VULCAN
     * @Date 2020/5/10 19:27
     */
    @RequestMapping(value = "pldelete/{ids}",method = RequestMethod.GET)
    public void delete(@PathVariable(value = "ids")Integer[] ids){
        for (Integer id : ids){
            credentialsLogService.pldelete(id);
        }
    }
    /**
     * @name  id查询
     * @Author VULCAN
     * @Date 2020/5/10 19:27
     */
    @RequestMapping(value = "selectById/{jzId}/{jzId2}",method = RequestMethod.GET)
    public CredentialsLogSchedule selectById(@PathVariable(value = "jzId")Integer jzId , @PathVariable(value = "jzId2")Integer jzId2){
        CredentialsLogSchedule  logSchedules = credentialsLogService.selectById(jzId,jzId2);
      return logSchedules;
    }
    /**
     * @name  修改
     * @Author VULCAN
     * @Date 2020/5/10 19:27
     */
    @RequestMapping(value = "update",method = RequestMethod.POST)
    public void update(@RequestBody CredentialsLogSchedule record){
        credentialsLogService.update(record);
    }
}
